<!--
 * @Author: taosong 2289713738@qq.com
 * @Date: 2024-01-06 16:12:00
 * @LastEditors: taosong 2289713738@qq.com
 * @LastEditTime: 2024-01-26 10:58:18
 * @FilePath: \Song-ui\src\components\Button\Button.vue
 * @Description: 
 * 
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. 
-->
<script setup lang="ts">
import { ref } from 'vue'
import type { ButtonProps } from './type'
import Icon from '../Icon/Icon.vue'
withDefaults(defineProps<ButtonProps>(), {
  nativeType: 'button'
})
defineOptions({
  name: 'SGButton'
})

const _ref = ref<HTMLButtonElement>()

defineExpose({
  ref: _ref
})
</script>

<template>
  <button
    class="sg-button"
    ref="_ref"
    :class="{
      [`sg-button--${type}`]: type,
      [`sg-button--${size}`]: size,
      'is-plain': plain,
      'is-round': round,
      'is-circle': circle,
      'is-disabled': disabled,
      'is-loading': loading
    }"
    :disabled="disabled || loading"
    :autofocus="autofocus"
    :type="nativeType"
  >
    <Icon icon="spinner" spin v-if="loading" />
    <Icon :icon="icon" spin v-if="icon" />
    <span>
      <slot />
    </span>
  </button>
</template>

<style></style>
